
function getMemberList(params) {
    return $axios({
        url: '/employees/employees_list',
        method: 'get',
        params
    })
}



const deleteEmployee = (id) => {
    return $axios({
        url: `/employees/delete/${id}`,
        method: 'post',
        params: {id}
    })
}
async function exportAllEmployees(ids) {
  return axios.post('/employees/batch_export', {
    ids: ids
  },{
    responseType: 'blob', // 指定返回类型为 Blob
  });
}


const uploadExcel = (formData) => {
    return $axios({
        url: '/employees/uploadExcel', // 后端上传 API 路径
        method: 'post',
        data: formData,
        headers: {
            'Content-Type': 'multipart/form-data' // 指明内容类型
        }
    });
};
// 新增---添加员工
function addEmployee(employeeData) {
    return $axios({
        url: '/employees/add',
        method: 'post',
        data: {
            em_name: employeeData.name, // 将 name 映射到 em_name
            email: employeeData.email,   // email 对应 email
            role: employeeData.role       // role 对应 role
        }
    })
}
function submitLeaveApplication(employeeId, leaveData) {
    return $axios({
        url: `/employees/edit/leave/${employeeId}`, // 确保这是正确的 API 路径
        method: 'POST',
        data: {
            status: leaveData.leaveType,     // 请假类型
            reason: leaveData.reason,         // 请假原因
            start_date: leaveData.startDate,  // 开始日期
            end_date: leaveData.endDate        // 结束日期
        }
    });
}

function submitBulkLeave(ids, leaveData) {
    return axios.post(`/employees/bulk_leave`, {
        ids: ids,
        status: leaveData.leaveType,  // 请假类型
        reason: leaveData.reason,      // 请假原因
        start_date: leaveData.startDate, // 开始日期
        end_date: leaveData.endDate     // 结束日期
    });
}

// 修改---添加员工
function editEmployee(employeeData) {
    return $axios({
        url: `/employees/edit/${employeeData.id}`, // 确保这是正确的 API 路径
        method: 'POST',
        data: {
            em_name: employeeData.name, // 将 name 映射到 em_name
            email: employeeData.email,   // email 对应 email
            role: employeeData.role       // role 对应 role
        }
    })
}
function deleteEmployees(ids) {
    return $axios({
        url: '/employees/bulk_delete', // 确保路径和后端一致
        method: 'delete',
        data: { ids } // 将 ID 列表作为请求体发送
    });
}

function editPaper(params) {
    return $axios({
        url: '/employees/edit',
        method: 'put',
        data: {...params}
    })
}

// 修改页面反查详情接口
function queryEmployeeById(id) {
    return $axios({
        url: `/user/${id}`,
        method: 'get'
    })
}